<template>
  <div class="edition-heart">
    <div class="banner"></div>
  </div>
  <div class="center">
    <!-- 精品列表 -->
    <div class="shops edition-heart">
      <div class="shops-top">
        <div class="shops-top-left">
          <img src="../../../public/images/jingpin.png" alt="" />
          <span>精品推荐</span>
        </div>
        <div class="shops-top-right">
          <span>更多</span>
          <img src="../../../public/images/arrow.png" alt="" />
        </div>
      </div>
      <Shops :arr="definesList" />
    </div>
    <!-- 精品列表 -->

    <!-- 热门兑换 -->
    <div class="shops edition-heart">
      <div class="shops-top">
        <div class="shops-top-left">
          <img src="../../../public/images/jingpin.png" alt="" />
          <span>热门兑换</span>
        </div>
        <div class="shops-top-right">
          <span>更多</span>
          <img src="../../../public/images/arrow.png" alt="" />
        </div>
      </div>
      <div style="padding-top: 22px;">
        <img src="../../../public/images/banner.4c6b6225.png" alt="" />
      </div>
      <Shops :arr="hotList" />
    </div>
    <!-- 热门兑换 -->
  </div>
  <!-- 积分攻略 -->
  <div class="strategy edition-heart">
    <div class="strategy-top">
      <img src="../../../public/images/score.png" alt="" />
      <span>积分攻略</span>
    </div>
    <div class="strategy-bottom">
      <div v-for="item in strategyList" :key="item.title">
        <img :src="item.img" alt="" />
        <p>{{ item.title }}</p>
        <div class="button">{{ item.cur }}</div>
      </div>
    </div>
  </div>
  <!-- 积分攻略 -->
</template>

<script setup lang="ts">
import { ApiProductsRecommend, ApiProductsHot } from './api'
import { ref, getCurrentInstance } from 'vue'
import Shops from '@/components/shops/shops.vue'

const { proxy } = getCurrentInstance() as { proxy: any }

// 精品推荐
const definesList = ref<IRecord[]>([])

// 热门兑换
const hotList = ref<IRecord[]>([])

ApiProductsRecommend().then((res) => {
  if (res.code === 0) {
    definesList.value = res.data?.data.records!
  }
})

ApiProductsHot().then((res) => {
  if (res.code === 0) {
    hotList.value = res.data?.data.records!
  }
})

// 积分攻略
const strategyList = [
  {
    img: new URL(
      '../../../public/images/integral-01.9386d4bf.png',
      import.meta.url,
    ).href,
    title: '签到得鸡腿',
    cur: '去签到',
  },
  {
    img: new URL(
      '../../../public/images/integral-02.150d92a1.png',
      import.meta.url,
    ).href,
    title: '购课得鸡腿',
    cur: '去购课',
  },
  {
    img: new URL(
      '../../../public/images/integral-03.9870f3f1.png',
      import.meta.url,
    ).href,
    title: '推荐得鸡腿',
    cur: '去推荐',
  },
  {
    img: new URL(
      '../../../public/images/integral-04.afadcbdf.png',
      import.meta.url,
    ).href,
    title: '做任务得鸡腿',
    cur: '做任务',
  },
]
</script>

<style lang="less" scoped>
.banner {
  width: 1200px;
  height: 446px;
  background-image: url('../../../public/images/banner.f559b49d.png');
  margin-bottom: 30px;
}
.center {
  background-color: #f5f5f5;
  padding-bottom: 56px;
  .shops {
    padding-top: 55px;

    .shops-top {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .shops-top-left {
        display: flex;
        align-items: center;
        span {
          font-size: 30px;
          font-weight: bold;
          padding-left: 10px;
        }
      }
      .shops-top-right {
        display: flex;
        align-items: center;
        cursor: pointer;
        span {
          font-size: 16px;
          padding-right: 6px;
        }
      }
    }
    .shops-bottom {
      ul {
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 1200px;
        li {
          width: 285px;
          display: flex;
          flex-direction: column;
          background-color: #fff;
          align-items: center;
          padding-bottom: 32px;
          margin-right: 20px;
          margin-top: 22px;
          position: relative;

          &:nth-of-type(4n) {
            margin-right: 0;
          }
          .title-pic {
            position: absolute;
            top: 0;
            left: 0;
          }
          .pic {
            width: 100%;
            height: 330px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          span {
            &:nth-of-type(1) {
              padding-top: 22px;
              font-size: 18px;
              color: #333333;
            }
            &:nth-of-type(2) {
              margin-top: 16px;
              font-size: 18px;
              color: #fd604d;
              font-weight: bold;
            }
          }
          .button {
            width: 100px;
            height: 36px;
            margin-top: 20px;
            border: 1px solid #0a328e;
            line-height: 36px;
            text-align: center;
            color: #0a328e;
            cursor: pointer;
            &:hover {
              background-color: #0a328e;
              color: #fff;
            }
          }

          &:hover {
            transform: translateY(-23px);
            transition: transform 0.5s linear;
          }
        }
      }
    }
  }
}

.strategy {
  padding-top: 50px;
  padding-bottom: 47px;
  .strategy-top {
    display: flex;
    align-items: center;
    span {
      padding-left: 10px;
      font-weight: bold;
      font-size: 30px;
    }
  }
  .strategy-bottom {
    padding-top: 23px;
    display: flex;
    justify-content: space-between;

    div {
      position: relative;
      width: 285px;
      height: 168px;
      overflow: hidden;
      &:hover {
        img {
          transform: scale(1.3);
          transition: transform 1.5s linear;
        }
      }
      p {
        position: absolute;
        top: 43px;
        left: 20px;
        font-weight: bold;
        font-size: 24px;
        color: #fff;
      }
      .button {
        position: absolute;
        bottom: 50px;
        left: 20px;
        width: 96px;
        height: 27px;
        border: 1px solid #fff;
        color: #fff;
        text-align: center;
        line-height: 27px;
        font-size: 16px;
        cursor: pointer;
      }
    }
  }
}
</style>
